package com.tanhua.app.controller;

import com.aliyuncs.exceptions.ClientException;
import com.tanhua.app.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping(value = "/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    @PostMapping(value = "/location", name = "上传用户地理位置")
    public ResponseEntity location(@RequestBody Map<String,String> map) throws ClientException, IOException {

        double y_longitude =Double.parseDouble(map.get("longitude")); //经度
        double x_latitude =Double.parseDouble(map.get("latitude")); //纬度
        String addrStr =map.get("addrStr"); //地理信息
        y_longitude=116.635672;
        x_latitude=40.169419;
        addrStr="黑马程序员(顺义校区)";
        return baiduService.location(y_longitude,x_latitude,addrStr);
    }

}
